package com.itheima.blackitheima;

import java.util.Iterator;
import java.util.TreeSet;

public class MyTreeSet1 {
    public static void main(String[] args) {
        //创建TreeSet集合
        TreeSet<Student> ts=new TreeSet<>();
        //创建Student类对象
        Student stu1=new Student("zhangsan",23);
        Student stu2=new Student("wangwu",24);
        Student stu3=new Student("lilihua",28);
        Student stu4=new Student("miaoweijian",21);
        ts.add(stu1);
        ts.add(stu2);
        ts.add(stu3);
        ts.add(stu4);
        //迭代器
        Iterator<Student> it = ts.iterator();
        while(it.hasNext()){
            System.out.println(it.next());
        }
        System.out.println("==============");
        //超级for
        for (Student t : ts) {
            System.out.println(t);
        }
    }
}
